#!/bin/bash

# ============================================
# Worker Start Script (macOS/Linux)
# ============================================

# Get script directory and change to project root
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR/../.."

# Activate virtual environment if exists
if [ -d "venv" ]; then
    source venv/bin/activate
    echo "[OK] Virtual environment activated"
fi

# Set Hugging Face mirror for China users
export HF_ENDPOINT=https://hf-mirror.com

# Check if config file exists
if [ ! -f "config/worker_config.json" ]; then
    echo "[ERROR] Config file not found"
    echo "Please run: ./scripts/unix/config_wizard.sh"
    exit 1
fi

# Start Worker
echo "Starting Worker service..."
echo "===================="
python3 worker.py "$@"
